#ifndef _MMPF_USBDESCR_H
#define _MMPF_USBDESCR_H

#include    "config_fw.h"
#define  HIBYTE(v1)     ( (MMP_UBYTE)((v1)>>8) )
#define  LOBYTE(v1)     ( (MMP_UBYTE)((v1)&0xff))

#define   MSSBYTE(v1)    ( (MMP_UBYTE)((v1)>>24)  )
#define   HISBYTE(v1)    ( (MMP_UBYTE)((v1)>>16)  )
#define   LOSBYTE(v1)    ( (MMP_UBYTE)((v1)>>8)   )
#define   LESBYTE(v1)    ( (MMP_UBYTE)((v1)&0xff) )
#define  SWAP_ULONG(v1)  (MSSBYTE(v1) + (HISBYTE(v1) << 8) + (LOSBYTE(v1) << 16) + (LESBYTE(v1) << 24))
#define  SWAP_USHORT(v1) (HIBYTE(v1) + (LOBYTE(v1) << 8))

//**********************************************************************************
// Stream and Format Enable
//**********************************************************************************

#if USB_FRAMEBASE_H264_ONLY || USB_FRAMEBASE_H264_YUY2_STREAM || USB_FRAMEBASE_H264_MJPEG_STREAM || USB_FRAMEBASE_DUAL_H264_STREAM
    #define ENABLE_FRAME_BASE_H264 (0)//Frame Base calling flow & descriptor
#else
    #define ENABLE_FRAME_BASE_H264 (0)//Frame Base calling flow & descriptor
#endif

#define S1_ENABLE               1
#define S1_ENABLE_YUY2          ENABLE_YUY2
#define S1_ENABLE_MJPEG         ENABLE_MJPEG
#define S1_ENABLE_H264          ENABLE_FRAME_BASE_H264
#define S2_ENABLE_YUY2          ENABLE_YUY2
#define S2_ENABLE_MJPEG         ENABLE_MJPEG
#define S2_ENABLE_H264          ENABLE_FRAME_BASE_H264


#if (SWAP_VIDEO_FORMAT_INDEX == 0)  // YUY2 index is 1, MJPEG index is 2
//format index
#if ENABLE_YUY2
#define YUY2_FORMAT_INDEX (1)
#else
#define YUY2_FORMAT_INDEX (0)
#endif

#if ENABLE_MJPEG
#define MJPEG_FORMAT_INDEX (YUY2_FORMAT_INDEX+1)
#else
#define MJPEG_FORMAT_INDEX (YUY2_FORMAT_INDEX)
#endif

#if ENABLE_FRAME_BASE_H264
#define FRAME_BASE_H264_INDEX (MJPEG_FORMAT_INDEX+1)
#else
#define FRAME_BASE_H264_INDEX (MJPEG_FORMAT_INDEX)
#endif

#else  // MJPEG index is 1, YUY2 index is 2

//format index
#if ENABLE_MJPEG
#define MJPEG_FORMAT_INDEX (1)
#else
#define MJPEG_FORMAT_INDEX (0)
#endif

#if ENABLE_YUY2
#define YUY2_FORMAT_INDEX (MJPEG_FORMAT_INDEX+1)
#else
#define YUY2_FORMAT_INDEX (MJPEG_FORMAT_INDEX)
#endif

#if ENABLE_FRAME_BASE_H264
#define FRAME_BASE_H264_INDEX (YUY2_FORMAT_INDEX+1)
#else
#define FRAME_BASE_H264_INDEX (YUY2_FORMAT_INDEX)
#endif

#endif

#ifdef ENABLE_FRAME_BASE_AVC1
#define FRAME_BASE_AVC1_FORMAT_INDEX (FRAME_BASE_H264_INDEX+1)
#else
#define FRAME_BASE_AVC1_FORMAT_INDEX (FRAME_BASE_H264_INDEX)
#endif

// total numbers of video formats
#define TOTAL_NUM_VIDEO_FORMAT       (FRAME_BASE_AVC1_FORMAT_INDEX)

//**********************************************************************************
// descriptor length
//**********************************************************************************
#define NUM_OF_XU (2 + SKYPE_UVC_H264) // (EU1,EU2) + EU3
#define NUM_OF_SECS_XU   (SECS_VER > 0)  // EU0

#define USB_CFG_DESC_SIZE                                (0x09)
#define USB_IF_ASC_DESC_SIZE                             (0x08)
// IF0, AL0
#define USB_IF_UVC_CTL_DESC_SIZE                         (0x09)
#define USB_IF_UVC_STREAM_DESC_SIZE                      (0x09)
#define USB_IF_UAC_CTL_DESC_SIZE                         (0x09)

//input header descriptor length
#define NUM_OF_UVC_D1_CTL_IF                             (0x01) //always 1
#define NUM_OF_UVC_D1_STREAM_IF                          (1)//no use stream 2 yet
#define NUM_OF_UVC_D1_IF                                 (NUM_OF_UVC_D1_CTL_IF+NUM_OF_UVC_D1_STREAM_IF)

#define NUM_OF_UVC_D2_CTL_IF                             (((SUPPORT_DUAL_DEVICE==1)||(SUPPORT_SWITCH_CAMERA==1))?0x01:0) //always 1
#define NUM_OF_UVC_D2_STREAM_IF                          (((SUPPORT_DUAL_DEVICE==1)||(SUPPORT_SWITCH_CAMERA==1))?1:0)//no use stream 2 yet
#define NUM_OF_UVC_D2_IF                                 (((SUPPORT_DUAL_DEVICE==1)||(SUPPORT_SWITCH_CAMERA==1))?(NUM_OF_UVC_D2_CTL_IF+NUM_OF_UVC_D2_STREAM_IF):0)

#define UVC_D1_CTL_IF_NO                                 (0x00) //always 0
#define UVC_D1_STREAM_IF1_NO                             (UVC_D1_CTL_IF_NO+1) //always 1
#define UVC_D1_STREAM_IF2_NO                             (UVC_D1_STREAM_IF1_NO+0) //if not use, must equal to IF1. //always 2, no use stream 2 yet

#if SUPPORT_DUAL_DEVICE
#define UVC_D2_CTL_IF_NO                                 (UVC_D1_STREAM_IF2_NO+1)
#define UVC_D2_STREAM_IF1_NO                             (UVC_D2_CTL_IF_NO+1)
#define UVC_D2_STREAM_IF2_NO                             (UVC_D2_STREAM_IF1_NO+1) //no use stream 2 yet
#elif SUPPORT_SWITCH_CAMERA
#define UVC_D2_CTL_IF_NO                                 (4)//(UVC_D1_STREAM_IF2_NO+1)
#define UVC_D2_STREAM_IF1_NO                             (UVC_D2_CTL_IF_NO+1)
#define UVC_D2_STREAM_IF2_NO                             (UVC_D2_STREAM_IF1_NO+1) //no use stream 2 yet
#else
#define UVC_D2_CTL_IF_NO                                 (UVC_D1_CTL_IF_NO)
#define UVC_D2_STREAM_IF1_NO                             (UVC_D1_STREAM_IF1_NO)
#define UVC_D2_STREAM_IF2_NO                             (UVC_D1_STREAM_IF2_NO) //no use stream 2 yet
#endif

#define UAC_CTL_IF_NO                                    (UVC_D2_STREAM_IF2_NO+1)//(NUM_OF_UVC_D1_IF+NUM_OF_UVC_D2_IF)
#define UAC_STREAM_IF_NO                                 (UAC_CTL_IF_NO+1)
#define NUM_OF_UAC_CTL_IF                                (SUPPORT_UAC?1:0)
#define NUM_OF_UAC_STREAM_IF                             (SUPPORT_UAC?1:0)
#define NUM_OF_UAC_IF                                    (NUM_OF_UAC_CTL_IF+NUM_OF_UAC_STREAM_IF)

#define NUM_OF_TOTAL_IF                                  (NUM_OF_UVC_D1_IF+(NUM_OF_UVC_D2_IF*SUPPORT_DUAL_DEVICE)+NUM_OF_UAC_IF+SUPPORT_HID_FUNC)
#if (SUPPORT_SWITCH_CAMERA)
#define NUM_OF_CONFIG_1_TOTAL_IF                         (NUM_OF_UVC_D1_IF+NUM_OF_UAC_IF)
#define NUM_OF_CONFIG_2_TOTAL_IF                         (NUM_OF_UVC_D2_IF+NUM_OF_UAC_IF)
#endif

#define USB_UVC_IF_CTL_HEADER_DESC_SIZE                  (0x0c+NUM_OF_UVC_D1_STREAM_IF)
#define USB_UVC_IF_CTL_OT_DESC_SIZE                      (0x09)
#define USB_UVC_IF_CTL_XU_DESC_SIZE                      (0x1B)
#define USB_UVC_IF_CTL_IT_DESC_SIZE                      (0x12)
#define USB_UVC_IF_CTL_PU_DESC_SIZE                      (0x0b)
#define USB_UVC_IF_CTL_SECS_XU_DESC_SIZE                 (0x1D)
#define USB_UVC_IF_CTL_TOTAL_SIZE                        ( USB_UVC_IF_CTL_HEADER_DESC_SIZE+       \
                                                           USB_UVC_IF_CTL_OT_DESC_SIZE*           \
                                                           NUM_OF_UVC_D1_STREAM_IF+               \
                                                           USB_UVC_IF_CTL_XU_DESC_SIZE*NUM_OF_XU+ \
                                                           USB_UVC_IF_CTL_SECS_XU_DESC_SIZE*      \
                                                           NUM_OF_SECS_XU+                        \
                                                           USB_UVC_IF_CTL_IT_DESC_SIZE+           \
                                                           USB_UVC_IF_CTL_PU_DESC_SIZE           )


#define USB_EP_DESC_SIZE                                 (0x07)
#define USB_UVC_EP_INT_DESC_SIZE                         (0x05)


#if S1_ENABLE_YUY2
#define USB_UVC_S1_IF_STREAM_FORMAT_YUY2_DESC_SIZE       (0x1b)
#define USB_UVC_S1_IF_STREAM_FRAME_YUY2_DESC_SIZE        (0x1A + MFPS * 4)
#define USB_UVC_S2_IF_STREAM_FORMAT_YUY2_DESC_SIZE       (0x1b)
#define USB_UVC_S2_IF_STREAM_FRAME_YUY2_DESC_SIZE        (0x1A + MFPS * 4)
#else
#define USB_UVC_S1_IF_STREAM_FORMAT_YUY2_DESC_SIZE       (0x00)
#define USB_UVC_S1_IF_STREAM_FRAME_YUY2_DESC_SIZE        (0x00)
#define USB_UVC_S2_IF_STREAM_FORMAT_YUY2_DESC_SIZE       (0x00)
#define USB_UVC_S2_IF_STREAM_FRAME_YUY2_DESC_SIZE        (0x00)
#endif
#if S1_ENABLE_MJPEG
#define USB_UVC_S1_IF_STREAM_FORMAT_MJPEG_DESC_SIZE      (0x0b)
#define USB_UVC_S1_IF_STREAM_FRAME_MJPEG_DESC_SIZE       (0x1A + MFPS * 4) // 1e + (MFPS-1)*4
#define USB_UVC_S2_IF_STREAM_FORMAT_MJPEG_DESC_SIZE      (0x0b)
#define USB_UVC_S2_IF_STREAM_FRAME_MJPEG_DESC_SIZE       (0x1A + MFPS * 4) // 1e + (MFPS-1)*4
#else
#define USB_UVC_S1_IF_STREAM_FORMAT_MJPEG_DESC_SIZE      (0x00)
#define USB_UVC_S1_IF_STREAM_FRAME_MJPEG_DESC_SIZE       (0x00)
#define USB_UVC_S2_IF_STREAM_FORMAT_MJPEG_DESC_SIZE      (0x00)
#define USB_UVC_S2_IF_STREAM_FRAME_MJPEG_DESC_SIZE       (0x00)
#endif
#if S1_ENABLE_H264
#define USB_UVC_S1_IF_STREAM_FORMAT_H264_DESC_SIZE       (0x1c)
#define USB_UVC_S1_IF_STREAM_FRAME_H264_DESC_SIZE        (0x26)
#define USB_UVC_S2_IF_STREAM_FORMAT_H264_DESC_SIZE       (0x1c)
#define USB_UVC_S2_IF_STREAM_FRAME_H264_DESC_SIZE        (0x26)
#else
#define USB_UVC_S1_IF_STREAM_FORMAT_H264_DESC_SIZE       (0x00)
#define USB_UVC_S1_IF_STREAM_FRAME_H264_DESC_SIZE        (0x00)
#define USB_UVC_S2_IF_STREAM_FORMAT_H264_DESC_SIZE       (0x00)
#define USB_UVC_S2_IF_STREAM_FRAME_H264_DESC_SIZE        (0x00)
#endif

#if (USING_STILL_METHOD_1 == 0)
#define USB_UVC_YUY2_STILL_DESC_SIZE                     (0x07+NUM_YUY2_STILL*4)
#define USB_UVC_MJPEG_STILL_DESC_SIZE                    (0x07+NUM_MJPG_STILL*4)
#else
#define USB_UVC_YUY2_STILL_DESC_SIZE                     (0)
#define USB_UVC_MJPEG_STILL_DESC_SIZE                    (0)
#endif
#define USB_UVC_COLOR_DESC_SIZE                          (0x06)

#define USB_UVC_S1_IF_STREAM_YUY2_STILL_IMAGE_DESC_SIZE  (USING_STILL_METHOD_1?0:USB_UVC_YUY2_STILL_DESC_SIZE)
#define USB_UVC_S1_IF_STREAM_MJPEG_STILL_IMAGE_DESC_SIZE (USING_STILL_METHOD_1?0:USB_UVC_MJPEG_STILL_DESC_SIZE)
//#define USB_UVC_S1_IF_STREAM_H264_STILL_IMAGE_DESC_SIZE
//#define USB_UVC_S1_IF_STREAM_COLOR_DESC_SIZE             USB_UVC_COLOR_DESC_SIZE


#define S1_NUM_OF_UVC_STREAM_FORMAT                      (S1_ENABLE_YUY2 + S1_ENABLE_MJPEG + S1_ENABLE_H264)
#define USB_UVC_S1_IF_STREAM_IHEADER_DESC_SIZE           (0x0d+S1_NUM_OF_UVC_STREAM_FORMAT*1)
#define S2_NUM_OF_UVC_STREAM_FORMAT                      (S2_ENABLE_YUY2 + S2_ENABLE_MJPEG + S2_ENABLE_H264)
#define USB_UVC_S2_IF_STREAM_IHEADER_DESC_SIZE           (0x0d+S2_NUM_OF_UVC_STREAM_FORMAT*1)


#if ENABLE_YUY2
    #define USB_UVC_YUV_FORMAT_DESC_SIZE                 (0x01B)
    #define USB_UVC_YUV_FRAME_DESC_SIZE                  (0x01E)
    #define YUY2_D1_DESC_LEN (USB_UVC_COLOR_DESC_SIZE + USB_UVC_YUV_FORMAT_DESC_SIZE + (USB_UVC_YUV_FRAME_DESC_SIZE * NUM_D1_YUY2_VIDEO) + USB_UVC_YUY2_STILL_DESC_SIZE)
    #define YUY2_D2_DESC_LEN (USB_UVC_COLOR_DESC_SIZE + USB_UVC_YUV_FORMAT_DESC_SIZE + (USB_UVC_YUV_FRAME_DESC_SIZE * NUM_D2_YUY2_VIDEO) + USB_UVC_YUY2_STILL_DESC_SIZE)
#else
    #define YUY2_D1_DESC_LEN (0x00)
    #define YUY2_D2_DESC_LEN (0x00)
#endif

#ifdef ENABLE_UYVY//need modify !!
#if (USING_STILL_METHOD_1)
#define UYVY_DESC_LEN (0xE9 - 0x13)//(0x0AD)//(0x097)//(0x08F)//(0x069)
#else
#define UYVY_DESC_LEN (0xE9)//(0x0AD)//(0x097)//(0x08F)//(0x069)
#endif
#else
#define UYVY_DESC_LEN (0x000)
#endif

#ifdef ENABLE_NV12//need modify !!
#define NV12_DESC_LEN (0x040)
#else
#define NV12_DESC_LEN (0x000)
#endif

#if ENABLE_MJPEG
    #define USB_UVC_MJPEG_FORMAT_DESC_SIZE               (0x00B)
    #define USB_UVC_MJPEG_FRAME_DESC_SIZE                (0x01E)
    #define MJPEG_D1_DESC_LEN (USB_UVC_COLOR_DESC_SIZE + USB_UVC_MJPEG_FORMAT_DESC_SIZE + (USB_UVC_MJPEG_FRAME_DESC_SIZE * NUM_D1_MJPG_VIDEO) + USB_UVC_MJPEG_STILL_DESC_SIZE)//(0x03B) // 0x1E for 1080P
    #define MJPEG_D2_DESC_LEN (USB_UVC_COLOR_DESC_SIZE + USB_UVC_MJPEG_FORMAT_DESC_SIZE + (USB_UVC_MJPEG_FRAME_DESC_SIZE * NUM_D2_MJPG_VIDEO) + USB_UVC_MJPEG_STILL_DESC_SIZE)//(0x03B) // 0x1E for 1080P
#else
    #define MJPEG_D1_DESC_LEN (0)
    #define MJPEG_D2_DESC_LEN (0)
#endif

#if ENABLE_FRAME_BASE_H264
    #define USB_UVC_H264_FORMAT_DESC_SIZE                (0x01C)
    #define USB_UVC_H264_FRAME_DESC_SIZE                 (0x026)
#define AIT1_DESC_LEN         (USB_UVC_COLOR_DESC_SIZE + USB_UVC_H264_FORMAT_DESC_SIZE + (USB_UVC_H264_FRAME_DESC_SIZE * NUM_H264_VIDEO))
#else
#define AIT1_DESC_LEN         (0x000)
#endif

#ifdef ENABLE_FRAME_BASE_AVC1//need modify !!
#define FRAME_BASE_AVC1_DESC_LEN (0x041)
#else
#define FRAME_BASE_AVC1_DESC_LEN (0x000)
#endif

//#define UVC_D1_INPUT_HEADER_LENGTH (0x07D+NV12_DESC_LEN+MJPEG_D1_DESC_LEN+FRAME_BASE_AVC1_DESC_LEN)
//#define UVC_D1_INPUT_HEADER_LENGTH (0x01F+(YUY2_D1_DESC_LEN)+(UYVY_DESC_LEN)+(NV12_DESC_LEN)+(MJPEG_D1_DESC_LEN)+(AIT1_DESC_LEN)+(FRAME_BASE_AVC1_DESC_LEN))
#define UVC_D1_INPUT_HEADER_LENGTH (USB_UVC_S1_IF_STREAM_IHEADER_DESC_SIZE+(YUY2_D1_DESC_LEN)+(UYVY_DESC_LEN)+(NV12_DESC_LEN)+(MJPEG_D1_DESC_LEN)+(AIT1_DESC_LEN)+(FRAME_BASE_AVC1_DESC_LEN))
#define UVC_D2_INPUT_HEADER_LENGTH (USB_UVC_S2_IF_STREAM_IHEADER_DESC_SIZE+(YUY2_D2_DESC_LEN)+(UYVY_DESC_LEN)+(NV12_DESC_LEN)+(MJPEG_D2_DESC_LEN)+(AIT1_DESC_LEN)+(FRAME_BASE_AVC1_DESC_LEN))

#if 1//SUPPORT_UAC
    #define USB_UAC_IF_CTL_HEADER_DESC_SIZE                  (0x09)
    #define USB_UAC_IF_CTL_IT_DESC_SIZE                      (0x0C)
    #define USB_UAC_IF_CTL_OT_DESC_SIZE                      (0x09)
    #define USB_UAC_IF_CTL_FU_DESC_SIZE                      (0x08)
    #define USB_UAC_IF_CTL_TOTAL_SIZE                        ( USB_UAC_IF_CTL_HEADER_DESC_SIZE+     \
                                                               USB_UAC_IF_CTL_OT_DESC_SIZE+         \
                                                               USB_UAC_IF_CTL_IT_DESC_SIZE+         \
                                                               USB_UAC_IF_CTL_FU_DESC_SIZE         )

    // IF3AL0  or IF4AL0    // IF3AL1  or IF4AL1
    #define USB_IF_UAC_STREAM_DESC_SIZE                      (0x09)

    #define USB_UAC_IF_STREAM_GENERAL_DESC_SIZE              (0x07)
    #define USB_UAC_IF_STREAM_FORMAT_PCM_DESC_SIZE           (0x08+0x03*NUM_OF_UAC_SAMPLING_RATE)
    #define USB_UAC_IF_STREAM_TOTAL_SIZE                     ( USB_UAC_IF_STREAM_GENERAL_DESC_SIZE+    \
                                                               USB_UAC_IF_STREAM_FORMAT_PCM_DESC_SIZE )

    #define USB_UAC_EP_DESC_SIZE                             (0x09)
    #define USB_UAC_EP_GENERAL_DESC_SIZE                     (0x07)
#else
    #define USB_UAC_IF_STREAM_FORMAT_PCM_DESC_SIZE           (0)
#endif

#if SUPPORT_HID_FUNC
	#define HID_EP_ADDR                                      (0x05)
    #define HID_MAX_PK_SIZE                                  (0x08)
    #define USB_IF_HID_DESC_SIZE                             (0x19)
    #define REPORT_DESCRIPTOR_LEN                            (0x2D)//mouse: (0x3E), keyboard:(0x3F)
    //#define REPORT_DESCRIPTOR_LEN								(0x2D)
#else
    #define USB_IF_HID_DESC_SIZE                             (0)
#endif

#define D1_DESCRIPTOR_LEN     (USB_IF_ASC_DESC_SIZE+                \
                               USB_IF_UVC_CTL_DESC_SIZE+            \
                               USB_UVC_IF_CTL_TOTAL_SIZE+           \
                               USB_EP_DESC_SIZE+                    \
                               USB_UVC_EP_INT_DESC_SIZE+            \
                               USB_IF_UVC_STREAM_DESC_SIZE+         \
                               UVC_D1_INPUT_HEADER_LENGTH+          \
                               USB_IF_UVC_STREAM_DESC_SIZE*         \
                               (USB_UVC_BULK_EP?0:1)+               \
                               USB_EP_DESC_SIZE)

#define D2_DESCRIPTOR_LEN     (USB_IF_ASC_DESC_SIZE+                \
                               USB_IF_UVC_CTL_DESC_SIZE+            \
                               USB_UVC_IF_CTL_TOTAL_SIZE+           \
                               USB_EP_DESC_SIZE+                    \
                               USB_UVC_EP_INT_DESC_SIZE+            \
                               USB_IF_UVC_STREAM_DESC_SIZE+         \
                               UVC_D2_INPUT_HEADER_LENGTH+          \
                               USB_IF_UVC_STREAM_DESC_SIZE*         \
                               (USB_UVC_BULK_EP?0:1)+               \
                               USB_EP_DESC_SIZE)

#define UAC_DESCRIPTOR_LEN    (USB_IF_ASC_DESC_SIZE+                \
                               USB_IF_UAC_CTL_DESC_SIZE+            \
                               USB_UAC_IF_CTL_TOTAL_SIZE+           \
                               USB_IF_UAC_STREAM_DESC_SIZE+         \
                               USB_IF_UAC_STREAM_DESC_SIZE+         \
                               USB_UAC_IF_STREAM_TOTAL_SIZE+        \
                               USB_UAC_EP_DESC_SIZE+                \
                               USB_UAC_EP_GENERAL_DESC_SIZE)

#define CAMERA_1_CONFIG_DESCRIPTOR_LEN (USB_CFG_DESC_SIZE+          \
                              (D1_DESCRIPTOR_LEN)+                  \
                              (UAC_DESCRIPTOR_LEN)*                 \
                              (SUPPORT_UAC))

#define CAMERA_2_CONFIG_DESCRIPTOR_LEN (USB_CFG_DESC_SIZE+          \
                              (D2_DESCRIPTOR_LEN)+                  \
                              (UAC_DESCRIPTOR_LEN)*                 \
                              (SUPPORT_UAC))

#define CONFIG_DESCRIPTOR_LEN (USB_CFG_DESC_SIZE+                   \
                              (D1_DESCRIPTOR_LEN)+                  \
                              (D2_DESCRIPTOR_LEN)*                  \
                              (SUPPORT_DUAL_DEVICE+SUPPORT_SWITCH_CAMERA)+                \
                              (UAC_DESCRIPTOR_LEN)*                 \
                              (SUPPORT_UAC)+                        \
                              (USB_IF_HID_DESC_SIZE))

#define S1_YUY2_FRAME_OFFSET  ( USB_CFG_DESC_SIZE+                                \
                                USB_IF_ASC_DESC_SIZE+                             \
                                USB_IF_UVC_CTL_DESC_SIZE+                         \
                                USB_UVC_IF_CTL_TOTAL_SIZE+                        \
                                USB_EP_DESC_SIZE+                                 \
                                USB_UVC_EP_INT_DESC_SIZE+                         \
                                USB_IF_UVC_STREAM_DESC_SIZE+                      \
                                USB_UVC_S1_IF_STREAM_IHEADER_DESC_SIZE+           \
                                USB_UVC_S1_IF_STREAM_FORMAT_YUY2_DESC_SIZE*       \
                                S1_ENABLE_YUY2                                   )


#define S2_YUY2_FRAME_OFFSET  ( USB_CFG_DESC_SIZE+                                \
                                USB_IF_ASC_DESC_SIZE+                             \
                                USB_IF_UVC_CTL_DESC_SIZE+                         \
                                USB_UVC_IF_CTL_TOTAL_SIZE+                        \
                                USB_EP_DESC_SIZE+                                 \
                                USB_UVC_EP_INT_DESC_SIZE+                         \
                                USB_IF_UVC_STREAM_DESC_SIZE+                      \
                                USB_UVC_S2_IF_STREAM_IHEADER_DESC_SIZE+           \
                                USB_UVC_S2_IF_STREAM_FORMAT_YUY2_DESC_SIZE*       \
                                S2_ENABLE_YUY2                                   )


#define S1_MJPEG_FRAME_OFFSET ( USB_CFG_DESC_SIZE+                                \
                                USB_IF_ASC_DESC_SIZE+                             \
                                USB_IF_UVC_CTL_DESC_SIZE+                         \
                                USB_UVC_IF_CTL_TOTAL_SIZE+                        \
                                USB_EP_DESC_SIZE+                                 \
                                USB_UVC_EP_INT_DESC_SIZE+                         \
                                USB_IF_UVC_STREAM_DESC_SIZE+                      \
                                USB_UVC_S1_IF_STREAM_IHEADER_DESC_SIZE+           \
                                USB_UVC_S1_IF_STREAM_FORMAT_YUY2_DESC_SIZE*       \
                                S1_ENABLE_YUY2+                                   \
                                USB_UVC_S1_IF_STREAM_FRAME_YUY2_DESC_SIZE*        \
                                NUM_D1_YUY2_VIDEO+                                \
                                USB_UVC_S1_IF_STREAM_YUY2_STILL_IMAGE_DESC_SIZE*  \
                                STILL_ENABLE+                                     \
                                USB_UVC_COLOR_DESC_SIZE*                          \
                                S1_ENABLE_YUY2+                                   \
                                USB_UVC_S1_IF_STREAM_FORMAT_MJPEG_DESC_SIZE*      \
                                S1_ENABLE_MJPEG                                  )


#define S2_MJPEG_FRAME_OFFSET ( USB_CFG_DESC_SIZE+                                \
                                USB_IF_ASC_DESC_SIZE+                             \
                                USB_IF_UVC_CTL_DESC_SIZE+                         \
                                USB_UVC_IF_CTL_TOTAL_SIZE+                        \
                                USB_EP_DESC_SIZE+                                 \
                                USB_UVC_EP_INT_DESC_SIZE+                         \
                                USB_IF_UVC_STREAM_DESC_SIZE+                      \
                                USB_UVC_S2_IF_STREAM_IHEADER_DESC_SIZE+           \
                                USB_UVC_S1_IF_STREAM_FORMAT_YUY2_DESC_SIZE*       \
                                S2_ENABLE_YUY2+                                   \
                                USB_UVC_S1_IF_STREAM_FRAME_YUY2_DESC_SIZE*        \
                                NUM_D1_YUY2_VIDEO+                                \
                                USB_UVC_S1_IF_STREAM_YUY2_STILL_IMAGE_DESC_SIZE*  \
                                STILL_ENABLE+                                     \
                                USB_UVC_COLOR_DESC_SIZE*                          \
                                S1_ENABLE_YUY2+                                   \
                                USB_UVC_S1_IF_STREAM_FORMAT_MJPEG_DESC_SIZE*      \
                                S1_ENABLE_MJPEG                                  )

/*
#if ENABLE_MJPEG
#define CONFIG_DESCRIPTOR_LEN (0x1B9+0x041) //0x1B9//0x1D7
#else
#define CONFIG_DESCRIPTOR_LEN 0x17E//0x19C//0x017E
#endif
*/
//**********************************************************************************
// descriptor table address
//**********************************************************************************
#define     DEVICE_QUALIFIER_DESCRIPTOR_DATA0_ADDR   (0)
#define     DEVICE_DESCRIPTOR_DATA0_ADDR             (DEVICE_QUALIFIER_DESCRIPTOR_DATA0_ADDR+0x0A)
#define     CONFIG_DESCRIPTOR_DATA0_ADDR             (DEVICE_DESCRIPTOR_DATA0_ADDR+0x12)
#define     DEVICE_QUALIFIER_DESCRIPTOR_DATA1_ADDR   (0)
#define     DEVICE_DESCRIPTOR_DATA1_ADDR             (DEVICE_QUALIFIER_DESCRIPTOR_DATA1_ADDR+0x0A)
#define     CONFIG_DESCRIPTOR_DATA1_ADDR             (DEVICE_DESCRIPTOR_DATA1_ADDR+0x12)
#define     DEVICE_QUALIFIER_DESCRIPTOR_DATA2_ADDR   (0)
#define     DEVICE_DESCRIPTOR_DATA2_ADDR             (DEVICE_QUALIFIER_DESCRIPTOR_DATA2_ADDR+0x0A)
#define     CONFIG_DESCRIPTOR_DATA2_ADDR             (DEVICE_DESCRIPTOR_DATA2_ADDR+0x12)
#define     DEVICE_QUALIFIER_DESCRIPTOR_DATA3_ADDR   (0)
#define     DEVICE_DESCRIPTOR_DATA3_ADDR             (DEVICE_QUALIFIER_DESCRIPTOR_DATA3_ADDR+0x0A)
#define     CONFIG_DESCRIPTOR_DATA3_ADDR             (DEVICE_DESCRIPTOR_DATA3_ADDR+0x12)
#define     DEVICE_QUALIFIER_DESCRIPTOR_DATA4_ADDR   (0)
#define     DEVICE_DESCRIPTOR_DATA4_ADDR             (DEVICE_QUALIFIER_DESCRIPTOR_DATA4_ADDR+0x0A)
#define     CONFIG_DESCRIPTOR_DATA4_ADDR             (DEVICE_DESCRIPTOR_DATA4_ADDR+0x12)
#define     DEVICE_QUALIFIER_DESCRIPTOR_DATA5_ADDR   (0)
#define     DEVICE_DESCRIPTOR_DATA5_ADDR             (DEVICE_QUALIFIER_DESCRIPTOR_DATA5_ADDR+0x0A)
#define     CONFIG_DESCRIPTOR_DATA5_ADDR             (DEVICE_DESCRIPTOR_DATA5_ADDR+0x12)

#define     LANGUAGE_ID_DATA_ADDR                    (CONFIG_DESCRIPTOR_DATA1_ADDR+CONFIG_DESCRIPTOR_LEN)
#define     LANGUAGE_ID_DATA_ADDR1                   (CONFIG_DESCRIPTOR_DATA1_ADDR+CAMERA_1_CONFIG_DESCRIPTOR_LEN)
#define     LANGUAGE_ID_DATA_ADDR2                   (CONFIG_DESCRIPTOR_DATA1_ADDR+CAMERA_2_CONFIG_DESCRIPTOR_LEN)

//#if (CUSTOMER == NMG)
//#define     MANUFACTURER_STRING_DATA_ADDR           (LANGUAGE_ID_DATA_ADDR+0x04)
//#define     PRODUCT_STRING_DATA_ADDR                (MANUFACTURER_STRING_DATA_ADDR+0x06/*0x1E*/)
//#define     SERIALNUMBER_STRING_DATA_ADDR           (PRODUCT_STRING_DATA_ADDR+0x24/*0x1E*/)
//#define     DESCRIPTOR_TABLE_END_ADDR               (SERIALNUMBER_STRING_DATA_ADDR+0x1a)
//#elif (CUSTOMER == NKT)
//#define     MANUFACTURER_STRING_DATA_ADDR           (LANGUAGE_ID_DATA_ADDR+0x04)
//#define     PRODUCT_STRING_DATA_ADDR                (MANUFACTURER_STRING_DATA_ADDR+0x0E/*0x1E*/)
//#define     SERIALNUMBER_STRING_DATA_ADDR           (PRODUCT_STRING_DATA_ADDR+0x1C/*0x1E*/)
//#define     DESCRIPTOR_TABLE_END_ADDR               (SERIALNUMBER_STRING_DATA_ADDR+0x1a)
//#elif (CUSTOMER == LIT)
//#define     MANUFACTURER_STRING_DATA_ADDR           (LANGUAGE_ID_DATA_ADDR+0x04)
//#define     PRODUCT_STRING_DATA_ADDR                (MANUFACTURER_STRING_DATA_ADDR+0x08/*0x1E*/)
//#define     SERIALNUMBER_STRING_DATA_ADDR           (PRODUCT_STRING_DATA_ADDR+0x20/*0x1E*/)
//#define     DESCRIPTOR_TABLE_END_ADDR               (SERIALNUMBER_STRING_DATA_ADDR+0x0a)
//#elif ((CUSTOMER == CCN)&&(MODEL == 0))
//#define     MANUFACTURER_STRING_DATA_ADDR           (LANGUAGE_ID_DATA_ADDR+0x04)
//#define     PRODUCT_STRING_DATA_ADDR                (MANUFACTURER_STRING_DATA_ADDR+0x1C/*0x1E*/)
//#define     SERIALNUMBER_STRING_DATA_ADDR           (PRODUCT_STRING_DATA_ADDR+0x24/*0x1E*/)
//#define     DESCRIPTOR_TABLE_END_ADDR               (SERIALNUMBER_STRING_DATA_ADDR+0x1a)
//#elif ((CUSTOMER == CCN)&&(MODEL == 1))
//#define     MANUFACTURER_STRING_DATA_ADDR           (LANGUAGE_ID_DATA_ADDR+0x04)
//#define     PRODUCT_STRING_DATA_ADDR                (MANUFACTURER_STRING_DATA_ADDR+0x24/*0x1E*/)
//#define     SERIALNUMBER_STRING_DATA_ADDR           (PRODUCT_STRING_DATA_ADDR+0x2A/*0x1E*/)
//#define     DESCRIPTOR_TABLE_END_ADDR               (SERIALNUMBER_STRING_DATA_ADDR+0x1a)
//#else
//#define     MANUFACTURER_STRING_DATA_ADDR           (LANGUAGE_ID_DATA_ADDR+0x04)
//#define     PRODUCT_STRING_DATA_ADDR                (MANUFACTURER_STRING_DATA_ADDR+0x34/*0x1E*/)
//#define     SERIALNUMBER_STRING_DATA_ADDR           (PRODUCT_STRING_DATA_ADDR+0x2A/*0x1E*/)
//#define     DESCRIPTOR_TABLE_END_ADDR               (SERIALNUMBER_STRING_DATA_ADDR+0x1a)
//#endif


#if (SUPPORT_DPS_FUNC==1)
#define     DPS_LANGUAGE_ID_DATA_ADDR               CONFIG_DESCRIPTOR_DATA5_ADDR+0x27
#define     DPS_MANUFACTURER_STRING_DATA_ADDR       DPS_LANGUAGE_ID_DATA_ADDR+0x04
#define     DPS_PRODUCT_STRING_DATA_ADDR            DPS_MANUFACTURER_STRING_DATA_ADDR+0x1E
#define     DPS_SERIALNUMBER_STRING_DATA_ADDR       DPS_PRODUCT_STRING_DATA_ADDR+0x1E
#define     DPS_DESCRIPTOR_TABLE_END_ADDR           DPS_SERIALNUMBER_STRING_DATA_ADDR+0x12
#endif /* (SUPPORT_DPS_FUNC==1) */
#if (SUPPORT_MTP_FUNC==1)
#define     MTP_LANGUAGE_ID_DATA_ADDR               CONFIG_DESCRIPTOR_DATA4_ADDR+0x27
#define     MTP_MANUFACTURER_STRING_DATA_ADDR       MTP_LANGUAGE_ID_DATA_ADDR+0x04
#define     MTP_PRODUCT_STRING_DATA_ADDR            MTP_MANUFACTURER_STRING_DATA_ADDR+0x1E
#define     MTP_FRAME0_STRING_DATA_ADDR             MTP_PRODUCT_STRING_DATA_ADDR+0x1E
#define     MTP_FRAME1_STRING_DATA_ADDR             MTP_FRAME0_STRING_DATA_ADDR+0x0E
#define     MTP_DESCRIPTOR_TABLE_END_ADDR           MTP_FRAME1_STRING_DATA_ADDR+0x0E
#endif /* (SUPPORT_MTP_FUNC==1) */


#endif
